Convert a MongoDB code with MongoDB\Driver\Manager
NickName:Pim92 Ask DateTime:2018-02-14T19:25:04

Convert a MongoDB code with MongoDB\Driver\Manager

I'm trying to convert a code to access MongoDB using MongoDB\Driver\Manager: latest MongoDB extension of PHP, but have some difficulties. Indeed, this new driver seems to me a little bit low-level compared to the previous one so it can be a bit complicated to work with... :

$mongoConn = new MongoClient("mongodb://localhost:27017");
$mongoDB = $mongoConn->selectDataBase(dbname1);//dbname2 exists too
...
$index = new MongoDBIndexation($mongoDB);//our class for using

If it is ok that I must begin with:

$mongoConn = new MongoDB\Driver\Manager("mongodb://localhost:27017");

How to continue with $mongoDB, please?

And what are the equivalents of:

$collection->remove
$collection->save and
$collection->findOne ?

Thanks in advance

Copyright Notice:Content Author:「Pim92」,Reproduced under the CC 4.0 BY-SA copyright license with a link to the original source and this disclaimer.
Link to original article:https://stackoverflow.com/questions/48786036/convert-a-mongodb-code-with-mongodb-driver-manager

More about “Convert a MongoDB code with MongoDB\Driver\Manager” related questions